﻿Imports ajayumi.develop.win32.GRssReader.Google.Reader
Imports ajayumi.develop.win32.GRssReader.Service
Imports System.IO
Imports ajayumi.develop.VBasic.Core

Module Configs
    Public o_ReaderService As IReaderService = Nothing

    Public o_ReaderMode As ReaderMode = ReaderMode.Offline

    Public Const o_Source As String = "Ajayumi.Google.App"

    ' ''' <summary>
    ' ''' html文件归类的文件夹名称
    ' ''' </summary>
    ' ''' <remarks>一个html文件的保存路径应为：CacheFolder\o_HtmlFolderName\Title\UpdateTime\Title.Html</remarks>
    'Public Const o_HtmlFolderName As String = "htmls"

    ''' <summary>
    ''' image文件归类的文件夹名称
    ''' </summary>
    ''' <remarks>一个image文件的保存路径应为：CacheFolder\o_ImageFolderName\Title\UpdateTime\Title.(jpg|bmp|gif|png)</remarks>
    Public Const o_ImageFolderName As String = "images"


    ''' <summary>
    ''' 获取根级缓存文件夹路径
    ''' </summary>
    ''' <param name="subscriptionInfo"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetSubscriptionCacheFolder(subscriptionInfo As Model.SubscriptionInfo) As String
        Dim _Directory As String = Path.Combine(My.Settings.CacheFolder, "Unkown")
        If subscriptionInfo IsNot Nothing Then
            _Directory = Path.Combine(My.Settings.CacheFolder, _
                                      StringHelper.FilterInvalidChars(subscriptionInfo.TitleText))
        End If
        If Directory.Exists(_Directory) = False Then
            Directory.CreateDirectory(_Directory)
        End If
        Return _Directory
    End Function

    Public Function GetSubscriptionImageCacheFolder(subscriptionInfo As Model.SubscriptionInfo) As String
        Dim _Directory As String = Path.Combine(GetSubscriptionCacheFolder(subscriptionInfo), _
                                                o_ImageFolderName)
        If Directory.Exists(_Directory) = False Then
            Directory.CreateDirectory(_Directory)
        End If
        Return _Directory
    End Function

    Public Function GetDownloadCacheFolder() As String
        Dim _Directory As String = Path.Combine(My.Settings.CacheFolder, "DownloadCache")
        If Directory.Exists(_Directory) = False Then
            Directory.CreateDirectory(_Directory)
        End If
        Return _Directory
    End Function
End Module
